package com.ysy.tz.core.utils;

import com.github.pagehelper.PageInfo;
import com.ysy.tz.core.selfcomp.CustomerPagination;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.TableView;

public class ModelUtils {
    public ModelUtils() {
    }

    public static void setTableViewValue(PageInfo value, TableView tableView, CustomerPagination pagination) {
        Platform.runLater(() -> {
            pagination.setCurrentStartRow((int)value.getStartRow());
            pagination.setCurrentEndRow((int)value.getEndRow());
            pagination.setTotalRow((int)value.getTotal());
            pagination.setTotalPages(value.getPages());
            ObservableList tableData = FXCollections.observableArrayList(value.getList());
            tableView.setItems(tableData);
            pagination.refreshDisplaySkin();
        });
    }
}
